/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package hibernate.entityes;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Embeddable;

/**
 *
 * @author eleven
 */
@Embeddable
public class DistancePK implements Serializable {

    @Basic(optional = false)
    @Column(name = "FROMCITY")
    private String fromcity;
    @Basic(optional = false)
    @Column(name = "TOCITY")
    private String tocity;

    public DistancePK() {
    }

    public DistancePK(String fromcity, String tocity) {
        this.fromcity = fromcity;
        this.tocity = tocity;
    }

    public String getFromcity() {
        return fromcity;
    }

    public void setFromcity(String fromcity) {
        this.fromcity = fromcity;
    }

    public String getTocity() {
        return tocity;
    }

    public void setTocity(String tocity) {
        this.tocity = tocity;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (fromcity != null ? fromcity.hashCode() : 0);
        hash += (tocity != null ? tocity.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof DistancePK)) {
            return false;
        }
        DistancePK other = (DistancePK) object;
        if ((this.fromcity == null && other.fromcity != null) || (this.fromcity != null && !this.fromcity.equals(other.fromcity))) {
            return false;
        }
        if ((this.tocity == null && other.tocity != null) || (this.tocity != null && !this.tocity.equals(other.tocity))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "hibernate.entityes.DistancePK[ fromcity=" + fromcity + ", tocity=" + tocity + " ]";
    }
}
